package com.wx.gof.pattern.structural.flyweight;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName EmployeeFactory
 * @Author wx
 * @Description 员工单例容器工厂
 * @Date 2018-12-08-23:41
 */
public class EmployeeFactory {
    private final static Map<String, Employee> EMPLOYEE_MAP = new ConcurrentHashMap<>();

    public static Employee getManager(String department) {
        Manager manager = (Manager) EMPLOYEE_MAP.get(department);
        if (manager == null) {
            manager = new Manager(department);
            String reportContent = department+"部门汇报:此次报告的主要内容是......";
            System.out.println(" 创建报告:"+reportContent);
            manager.setReportContent(reportContent);
            EMPLOYEE_MAP.put(department,manager);
        }
        return manager;
    }

}
